<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateGroupCoursesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $table_name = 'group_courses';
        Schema::create($table_name, function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('tenant_id')->index()->comment('租户ID');
            $table->integer('coach_id')->index()->comment('教练ID,外键');
            $table->string('title')->comment('课程标题');
            $table->string('cover_url')->nullable()->comment('课程封面图片');
            $table->decimal('price')->default(0)->comment('课程价格');
            $table->string('tags')->comment('课程标签');
            $table->integer('people_number')->comment('上课人数');
            $table->integer('start_people_number')->comment('开课人数');
            $table->tinyInteger('schedule_type')->default(1)->comment('排课类型 1：按周，2：按日期');
            $table->tinyInteger('week')->nullable()->comment('排课周几');
            $table->date('date')->nullable()->comment('排课日期');
            $table->time('course_start_time')->nullable()->comment('上课开始时间');
            $table->time('course_end_time')->nullable()->comment('上课结束时间');
            $table->integer('deadline')->default(0)->comment('截止报名时间(分)');
            $table->text('intro')->nullable()->comment('课程简介');
            $table->text('notes')->nullable()->comment('课程须知');
            $table->integer('sort')->default(0)->comment('排序(值越大越靠前)');
            $table->integer('total_buy_count')->default(0)->comment('累计购买次数');
            $table->boolean('is_enable')->default(true)->comment('是否启用');
            $table->timestamps();
        });
        add_table_comment($table_name, '团课表');
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('group_courses');
    }
}
